package net.loyintean.pearlshell.wechat.model.common;

import net.loyintean.pearlshell.wechat.common.MessageTypeEnum;

public class TextMessageModel extends CommonMessageModel {

	private static final String emptyString = "";

	private String content = emptyString;

	public TextMessageModel() {
		super(MessageTypeEnum.text);
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public String asXml() {
		StringBuilder builder = new StringBuilder();

		builder.append("<xml>");
		builder.append("<ToUserName><![CDATA[" + this.getToUserName()
				+ "]]></ToUserName>");
		builder.append(" <FromUserName><![CDATA[" + this.getFromUserName()
				+ "]]></FromUserName> ");
		builder.append("<CreateTime>" + this.getCreateTime() + "</CreateTime>");
		builder.append("<MsgType><![CDATA[" + this.getMsgType().name()
				+ "]]></MsgType>");
		builder.append("<Content><![CDATA[" + this.getContent()
				+ "]]></Content>");
		builder.append("</xml>");

		return builder.toString();
	}

	/**
	 * 
	 * @author Loy-winters1224@163.com
	 * @see java.lang.Object#toString()
	 * 
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("TextMessageModel [");
		if (content != null) {
			builder.append("content=");
			builder.append(content);
			builder.append(", ");
		}
		if (super.toString() != null) {
			builder.append("toString()=");
			builder.append(super.toString());
		}
		builder.append("]");
		return builder.toString();
	}

}
